function submit(){
   var autoLoginFlag = $('#autoLoginFlag:checked').val();
    if (autoLoginFlag == 1) {
        autoLoginFlag = 1;
    }else{
        autoLoginFlag = 0;
    }
    var errStr = checkForm();
    if (errStr != "") {
        errorTips(errStr);
        return false;
    }
    $.ajax({

        type: "post",

        url: common.loginUrl,

        data:  $('#login_form').serialize(),

        // dataType: "json",

        success: function(result){
           //这里是解析的json数据   直接返回data
            var data= result;
            if (data.code == 0) {//登录成功
                errorTips("登录成功");
                //这里调用安卓方法
                window.wa.login(JSON.stringify(data.data),autoLoginFlag);
            }else{
                errorTips(data.msg);
            }

        },error:function () {
            console.log('登录失败');
        }

    });
}

function errorTips(msg,outTime) {//错误提示
    var node = $('.js_tooltips');
    if(outTime==null) outTime = 2000;
    node.text(msg);
    node.show();
    node.shake(5, 10, 400);
    setTimeout(function(){
        node.fadeOut(500);
    },outTime)
}
function checkForm() {//检查表单
    var account = $("#sg-account").val();
    var password = $("#sg-password").val();
    if (account == null || account.length <= 0) {
        return "账号不能为空";
    }
    if (password == null || password.length <= 0) {
        return "密码不能为空";
    }
    return "";
}
function cancelAccount() {
    $('#sg-account').val("");
    $('#sg-password').val("");
}
function pwdLook(bean) {
    if ($(bean).attr("src") === 'image/login_check_false.png') {
        $(bean).attr("src","image/login_check_true.png");
        $('#sg-password').attr("type", "text");
    }else{
        $(bean).attr("src","image/login_check_false.png");
        $('#sg-password').attr("type", "password");
    }

}
